<?php

class NLanguage {
	var $_default="ru";
	var $_lang ;
	var $lang2locale=array('ru'=>'ru_RU.utf8');
function __construct ($lang = NULL){
$this->setLanguage($lang);

}

function setLanguage($lang){
   if ($lang) {
	$this->_lang=$this->lang2locale[$lang];
   } else {
	$this->_lang=$this->lang2locale[$this->_default];
   }
	
}
function switch_gettext(){
$lang=$this->_lang;
 putenv("LANG = $lang");
setlocale(LC_ALL,$lang);
bindtextdomain ("system", ROOT_DIR."/locale");
textdomain ("system");
}
function &getInstance($lang) {
	static $_instance;
    if (!isset($_instance)) {
      $c = __CLASS__;
      $_instance = new $c($lang);
	$_instance->switch_gettext();
    }
    return $_instance;
  }

function _($text){$lang =& NFactory::getLanguage();
 return _($text);
}




}
?>